package Demo;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class Test1 {
    public static void main(String[] args) {
        System.out.println("任务即将启动");
        Timer t = new Timer();
        t.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("任务在3秒后启动");
                System.out.println("任务结束");
            }
        },3000);
        t.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("任务在2秒后启动");
                System.out.println("任务结束");
            }
        },2000);
        t.schedule(new TimerTask() {
            @Override
            public void run() {
                System.out.println("任务在1秒后启动");
                System.out.println("任务结束");
            }
        },1000);


    }
}
